﻿// =================================================================== 
// 项目说明
//====================================================================
// 文件： ERP_CgRelations.cs
// 创建时间：2016/12/1
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using CRMMis.Model;
using CRMMis.IDAL;


namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类  客户商品对照.
    /// </summary>
    public partial class ERP_CgRelationsDAL : IERP_CgRelationsDAL
    {
		//此处写查询数据的sql语句，


        //if QueryDataString==""，DAL层的GetList，GetRecordCount等函数将直接存取ERP_CgRelations表


        //if QueryDataString!=""，则DAL层的GetList，GetRecordCount等函数将存取该SQL语句，取代表
		//注意：所写sql语句执行结果的字段必须是唯一的

		private const string QueryDataString = @"SELECT a.*,b.CargoId as BCargoId,b.state as RState,c.CustomerName,(SELECT TOP 1 Supplyprice FROM
                ERP_CusCargo_Detail a1 WHERE a.CargoId=a1.CargoId ORDER BY a1.DetailId DESC) Supplyprice,b.CustomerId,b.Relationid,b.OwerDetailId,b.CusDetailId FROM ERP_CusCargo a
                LEFT JOIN (select * from ERP_CgRelations) b ON a.CustomId=b.CustomerId AND a.CargoId=b.CusCargoId
                LEFT JOIN ERP_Customer c ON a.CustomId=c.CustomerId";

    }
}
